package com.cqut.forum.entity;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * @author yangxun
 * Relation entity
 */
@Entity
@Table(name = "relation", catalog = "forum", uniqueConstraints = @UniqueConstraint(columnNames = "user_id"))
public class Relation implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer relationId;
	private User user;
	private Integer friendId;
	private Date relationTime;
	private Boolean isOnline;
	private String friendRemarkName;
	private String relationLevel;
	private Boolean isCare;
	// Constructors

	/** default constructor */
	public Relation() {
	}

	/** full constructor */
	public Relation(User user, Integer friendId, Date relationTime,
			Boolean isOnline, String friendRemarkName, String relationLevel,
			Boolean isCare) {
		this.user = user;
		this.friendId = friendId;
		this.relationTime = relationTime;
		this.isOnline = isOnline;
		this.friendRemarkName = friendRemarkName;
		this.relationLevel = relationLevel;
		this.isCare = isCare;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "relation_id", unique = true, nullable = false)
	public Integer getRelationId() {
		return this.relationId;
	}

	public void setRelationId(Integer relationId) {
		this.relationId = relationId;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id")
	//@OneToOne(fetch = FetchType.LAZY, mappedBy = "relation")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "friend_id")
	public Integer getFriendId() {
		return this.friendId;
	}

	public void setFriendId(Integer friendId) {
		this.friendId = friendId;
	}

	@Column(name = "relation_time", length = 10)
	public Date getRelationTime() {
		return this.relationTime;
	}

	public void setRelationTime(Date relationTime) {
		this.relationTime = relationTime;
	}

	@Column(name = "is_online")
	public Boolean getIsOnline() {
		return this.isOnline;
	}

	public void setIsOnline(Boolean isOnline) {
		this.isOnline = isOnline;
	}

	@Column(name = "friend_remark_name", length = 20)
	public String getFriendRemarkName() {
		return this.friendRemarkName;
	}

	public void setFriendRemarkName(String friendRemarkName) {
		this.friendRemarkName = friendRemarkName;
	}

	@Column(name = "relation_level", length = 10)
	public String getRelationLevel() {
		return this.relationLevel;
	}

	public void setRelationLevel(String relationLevel) {
		this.relationLevel = relationLevel;
	}
	@Column(name = "is_care")
	public Boolean getIsCare() {
		return isCare;
	}

	public void setIsCare(Boolean isCare) {
		this.isCare = isCare;
	}

}